package beans;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import dataStorage.DBData;



@ManagedBean(name="userBean")
@SessionScoped
public class User {

	private String username;
	private String password;
	private boolean loggedIn;
	private int ID;
	
	public User(){
		username = "";
		password = "";
		loggedIn = false;
		//ID = 1;
	}
	
	public User(String username, String password){
		this.username = username;
		this.password = password;
	}
	
	public String getUsername() {
		try {
			DBData.getConnection();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public boolean isLoggedIn() {
		return loggedIn;
	}
	public void setLoggedIn(boolean loggedIn) {
		this.loggedIn = loggedIn;
	}
	public synchronized String loginUser(){
		if (!loggedIn) return "failure";
		return "success";
	}
	
	public int getID() {
		return ID;
	}
	public void setID(int iD) {
		ID = iD;
	}
	
}
